/*
 *  Copyright (C) 2003,14 R. De Graeve & B. Parisse,
 *  Institut Fourier, 38402 St Martin d'Heres
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#if !defined CASPP_MODELS_VARIOUS_H
#define CASPP_MODELS_VARIOUS_H

#include <caspp/config.h>
#include <string>
#include <iostream>
#include "models/basics.h"
#include "models/t_vector.h"

CASPP_NS_BEGIN

template <class T> class std_matrix: public std::vector< dbgprint_vector<T> > {
public:
    // inherited constructors
    std_matrix() : std::vector< dbgprint_vector<T> >::vector() { };
    std_matrix(int i) : std::vector< dbgprint_vector<T> >::vector(i) { };
    std_matrix(int i,const dbgprint_vector<T> & v) : std::vector< dbgprint_vector<T> >::vector(i,v) { };
    std_matrix(int i,int j) : std::vector< dbgprint_vector<T> >::vector(i,dbgprint_vector<T>(j)) { };
    std_matrix(int i,int j,const T & t) : std::vector< dbgprint_vector<T> >::vector(i,dbgprint_vector<T>(j,t)) { };
    // ~dbgprint_vector() { };
    // inherited destructors
    std_matrix<T> transpose() const {
        if (std::vector< dbgprint_vector<T> >::empty())
            return *this;
        int n=std::vector< dbgprint_vector<T> >::size();
        int m=std::vector< dbgprint_vector<T> >::front().dbgprint_vector<T>::size();
        std_matrix<T> res(m,n);
        typename std_matrix<T>::const_iterator it=std::vector< dbgprint_vector<T> >::begin();
        for (int i=0;i<n;++i,++it) {
            for (int j=0;j<m;++j)
                res[j][i]=(*it)[j];
        }
        return res;
    }
    std_matrix<T> transconjugate() const {
        if (std::vector< dbgprint_vector<T> >::empty())
            return *this;
        int n=std::vector< dbgprint_vector<T> >::size();
        int m=std::vector< dbgprint_vector<T> >::front().dbgprint_vector<T>::size();
        std_matrix<T> res(m,n);
        typename std_matrix<T>::const_iterator it=std::vector< dbgprint_vector<T> >::begin();
        for (int i=0;i<n;++i,++it) {
            for (int j=0;j<m;++j)
                res[j][i]=conj((*it)[j],0);
        }
        return res;
    }
    void dbgprint() { COUT << *this << std::endl; }
};

struct user_function {
    std::string s;
    int parser_token;
    user_function():s(""),parser_token(-1) {};
    user_function(const std::string & mys,int i):s(mys),parser_token(i) {};
};

CASPP_NS_END

#endif // CASPP_MODELS_VARIOUS_H
